from rest_framework import serializers

from spits.models import Spit
from users.models import User


class GetSpitListUserSerializers(serializers.ModelSerializer):
    '''user serializers'''

    class Meta:

        model = User

        fields = ('id','nickname','avatar')


class GetSpitListSerializers(serializers.ModelSerializer):
    '''get all spit'''

    state = serializers.IntegerField(label='state',read_only=True,default=0)

    user = GetSpitListUserSerializers(read_only=True)

    collected = serializers.BooleanField(label='collected',default=False,read_only=True)

    hasthumbup = serializers.BooleanField(label='hasthumbup',default=False,read_only=True)

    class Meta:

        model = Spit

        fields = '__all__'


class RetriveSpitListSerializers(serializers.ModelSerializer):

    ''''''
    user = GetSpitListUserSerializers(read_only=True)

    class Meta:

        model = Spit
        fields = '__all__'